//#include "main.h"
#include "data_global.h"
//#include "data_global.c"
//#include "sqlite_link_list.h"
extern pthread_mutex_t mutex_buzzer;
extern pthread_cond_t cond_buzzer;
extern int dev_buzzer_fd;
extern unsigned char dev_buzzer_mask;
void *pthread_buzzer(void *arg)
{
	puts("pthread_buzzer ok!!!");
    while(1)
    {
        pthread_mutex_lock(&mutex_buzzer);
        pthread_cond_wait(&cond_buzzer,&mutex_buzzer);
		puts("wake up");
        dev_buzzer_fd = open("/dev/beep",O_RDWR);
        if(dev_buzzer_fd < 0)
        {
            perror("fail to open");
			exit(1);
        }
#if 1
		printf("mask = %d\n",dev_buzzer_mask);
		while(1)
		{
			if(dev_buzzer_mask == 1)
			{
				ioctl(dev_buzzer_fd,BEEP_ON);
			}
			else
			{
				ioctl(dev_buzzer_fd,BEEP_OFF);
				break;
			}
		}
#endif
#if 0
		while(1)
		{
			ioctl(dev_buzzer_fd,BEEP_ON);
			usleep(1000);
			ioctl(dev_buzzer_fd,BEEP_OFF);
		}
#endif
        pthread_mutex_unlock(&mutex_buzzer);
        close(dev_buzzer_fd);
    }
    return arg;
}
